<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>产品列表</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="images/icons/favicon.ico">
    <link rel="apple-touch-icon" href="images/icons/favicon.png">
    <link rel="apple-touch-icon" sizes="72x72" href="images/icons/favicon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114" href="images/icons/favicon-114x114.png">
    <!--Loading bootstrap css-->
    <link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,700">
    <link type="text/css" rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700,300">
    <link type="text/css" rel="stylesheet" href="styles/jquery-ui-1.10.4.custom.min.css">
    <link type="text/css" rel="stylesheet" href="styles/font-awesome.min.css">
    <link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css">
    <link type="text/css" rel="stylesheet" href="styles/all.css">
    <link type="text/css" rel="stylesheet" href="styles/main.css">
    <link type="text/css" rel="stylesheet" href="styles/style-responsive.css">
    <link type="text/css" rel="stylesheet" href="styles/jplist-custom.css">
    <style>
	/*分页时底部样式*/
	.dibu-r ul,li{margin:0;padding:0;}
	.dibu-r ul{list-style:none;}
	.dibu{ width:100%;  margin:auto;font-size:18px; font-family:"微软雅黑"; color:#6f6e6e;  margin-top:15px; margin-bottom:50px;}
	.dibu span{ color:#3792f2;}
	.dibu p{ float:left;}
	.dibu-l{ float:left; width:70%;}
	.dibu-r{ float:right; width:30%; }
	.dibu-r li{ float:left; margin-right:10px; font-size:18px; font-family:"微软雅黑"; color:#8b8d90;}
	.dibu-r a{ float:left; margin-right:10px; margin-top:4px;}
	.xiala-yema{ width:42px; height:22px; border:#d3d5db 1px solid; border-radius:3px; color:#6f6e6e; font-size:14px;}
	.yema-xz{ color:#fd9162;}
	.dibu-r a:hover{filter:alpha(opacity=70); -moz-opacity:0.7;opacity:0.7; cursor:pointer;}
	.dibu-r li:hover{filter:alpha(opacity=70); -moz-opacity:0.7;opacity:0.7; cursor:pointer;}
	
	.modal-input{
        position:fixed;
        left:50%;
        top:45%;
        height:80%;
        width:90%;
        z-index:99999;
        transform: translate(-50%,-50%);
        overflow-y: scroll;
        border:5px solid #bbb;
    }
    .modal-mask{
        position:fixed;
        height:100%;
        width:100%;
        top:0;
        left:0;
        background:rgba(0,0,0,.3);
        z-index:9999;
    }
    .modal-close{
        position:absolute;
        top:0;
        right:0;
        height:36px;
        width:36px;
        font-size:24px;
        text-align:center;
        cursor:pointer;
    }
    
	</style>
</head>
<body onload="getProduct(1);getMainType();hideModal();">
<!-- 页面内容 -->
<div class="page-content">
    <div id="tab-general">
        <div class="row mbl">
            <div class="col-lg-12">
                <div class="col-md-12">
                    <div id="area-chart-spline" style="width: 100%; height: 300px; display: none;"></div>
                </div>                                
            </div>
			<div class="col-lg-12">                           
				<div class="page-content">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="panel">
                            <div class="panel-body">
                                <div id="grid-layout-table-1" class="box jplist">
									<!-- 查询条件选择栏 -->
                                    <div class="jplist-panel box panel-top">
                                        <div class="jplist-drop-down">
                                            <select class="form-control category-first" onchange="getChildType()">
												<option value='0' selected>--请选择--</option>																							
											</select>
                                        </div>
                                        <div class="jplist-drop-down">
                                            <select class="form-control category-second">
												<option value='0' selected>--请选择--</option>																							
											</select>
                                        </div>
                                        <div class="text-filter-box">
                                            <div class="input-group">
                                            	<span class="input-group-addon"><i class="fa fa-search"></i></span>
                                            	<input data-path=".title" type="text" value="" placeholder="产品名查找" class="form-control search-key"/>
                                            </div>
                                        </div>
										<button type="button" class="jplist-reset-btn btn btn-default" onclick="searchBtnClick()">搜 索<i class="fa fa-search mls"></i></button>
                                    </div>
									
									<!-- 分页查询内容展示 -->									
                                    <div class="box text-shadow">
                                        <table class="demo-tbl product-content">
                                        		                                       	                                   					
                                        </table>
                                    </div>
									
									<!-- 没有找到查询结果展示信息框 -->
                                    <div class="box jplist-no-results text-shadow align-center">                                    	
										<table class="demo-tbl">
                                            <tr class="tbl-item"><td>很抱歉！<p style="color:red">没有找到符合条件的结果</p></td></tr>
										</table>										
									</div>
                                    
									<!-- 分页按钮 -->
                                    <div class="jplist-panel box panel-bottom">
                                        <div class="dibu" id="pageDiv">
             								<div class="dibu-l">
                 								<p>共找到<span style="color:#4bc5c3;" id="totalCount">0</span>条记录，每页</p>
                 								<select name="cars" id="pageSize" onchange="getProduct(1)" style="width:80px">
                 									<option value="10">10</option>
                            						<option value="20" selected>20</option>
                            						<option value="30">30</option>
                 								</select>
                 								<p>条</p>
             								</div>
             								<div class="dibu-r">
             									<a href="javascript:void(0)" id="prePage">&lt;&lt;首页</a>
												<!-- img id="prePage" src="images/jianyou-you.png" title="首页"/-->												
                  								<ul id="newpage">
                     								
                  								</ul>
                  								<a href="javascript:void(0)" id="postPage">尾页&gt;&gt;</a>
                  								<!-- img id="postPage" src="images/jiantou-left.png" title="尾页"/-->
             								</div>
         								</div>
                                    </div>
									
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            	</div>
            </div>
        </div>
    </div>
</div>
<!-- 页面内容结束 -->

<!-- 弹出框 -->
<div class="modal-container">
    <div class="modal-mask"></div>
        <div id="generalTabContent" class="tab-content modal-input">
            <div class="modal-close" onclick="hideModal()">X</div>
            <div id="tab-edit" class="tab-pane fade in active">
                <form action="#" class="form-horizontal" id="productForm">											
                    <h3>产品信息</h3>
                    <div class="form-group"><label class="col-sm-3 control-label">产品名称</label>
                        <div class="col-sm-9 controls">
                            <div class="row">
                                <div class="col-xs-9">
                                	<input type="hidden" name="pId" value="0" class="edit-pId"/>
                                	<input type="text" placeholder="请输入产品名称" name="pName" class="form-control product-name"/>
                                </div>
                            </div>
                        </div>
                     </div>
                     <div class="form-group"><label class="col-sm-3 control-label">原价</label>
                         <div class="col-sm-9 controls">
                             <div class="row">
                                 <div class="col-xs-4"><input id="datepicker-normal" type="number" name="price" class="form-control old-price"/></div>
                             </div>
                         </div>
                     </div>
					 <div class="form-group"><label class="col-sm-3 control-label">现价</label>
                         <div class="col-sm-9 controls">
                             <div class="row">
                                 <div class="col-xs-4"><input id="datepicker-normal" type="number" name="currentPrice" class="form-control current-price"/></div>
                             </div>
                         </div>
                     </div>                                    
                     <div class="form-group"><label class="col-sm-3 control-label">一级类别</label>
                         <div class="col-sm-9 controls">
                             <div class="row">
                                 <div class="col-xs-4"><select name="parent" class="form-control edit-first"  onchange="getEditSecond(0)">
                                     <option value="0">--请选择--</option>
                                 </select></div>
                             </div>
                        </div>
                     </div>
                     <div class="form-group"><label class="col-sm-3 control-label">二级类别</label>
                         <div class="col-sm-9 controls">
                             <div class="row">
                                 <div class="col-xs-4"><select name="cId" class="form-control edit-second">
                                     <option value="0">--请选择--</option>
                                 </select></div>
                             </div>
                         </div>
                     </div>
                     <div class="form-group"><label class="col-sm-3 control-label">销量</label>
                         <div class="col-sm-9 controls">
                             <div class="row">
                                 <div class="col-xs-4"><input id="datepicker-normal" value="0" type="number" name="sales" class="form-control sales"/></div>
                             </div>
                         </div>
                     </div>
                     </form>
                     
                     <form action="/Beauty/product/uploadPic.do" method="post" id="titlePicForm" class="form-horizontal" enctype="multipart/form-data">
                     <div class="form-group"><label class="col-sm-3 control-label">产品logo</label>
                         <div class="col-sm-9 controls">
                             <div class="row">
                                 <div class="col-xs-4">
                                     <input id="logo-uploadImg" type="file" accept=".jpg,.jpeg,.png" name="pic" class="form-control"/>
                                     <img id="logo-uploadImg-show"></img> 
                                 </div>
                             </div>
                         </div>
                     </div>
                     </form>
                     
                     <form action="/Beauty/product/uploadPic.do" method="post" id="decPicForm" class="form-horizontal" enctype="multipart/form-data">
                     <div class="form-group"><label class="col-sm-3 control-label">产品详情</label>
                         <div class="col-sm-9 controls">
                             <div class="row">
                                 <div class="col-xs-4">
                                     <input id="dec-uploadImg" type="file" accept=".jpg,.jpeg,.png" name="pic" class="form-control"/>
                                     <div style="overflow-y:auto;overflow-x:hidden" id="dec-scroll">
                                     	<img id="dec-uploadImg-show"></img>
                                     </div>
                                 </div>
                             </div>
                         </div>
                     </div>
                     </form>
                     
                     <hr/>                                            
                     <button type="submit" class="btn btn-green btn-block" onclick="submitProduct()">提 交</button>
          </div>
     </div>                   
</div>
<!-- 弹出框结束 -->
				
<script src="script/jquery-1.10.2.min.js"></script>
<script src="script/jquery-migrate-1.2.1.min.js"></script>
<script src="script/jquery-ui.js"></script>
<script src="script/bootstrap.min.js"></script>
<script src="script/bootstrap-hover-dropdown.js"></script>
<script src="script/html5shiv.js"></script>

<script src="script/jquery.metisMenu.js"></script>
<script src="script/jquery.slimscroll.js"></script>
    
<script src="script/icheck.min.js"></script>

<script src="script/jquery.menu.js"></script>
<script type="text/javascript" src="script/layer/layer.js"></script>

<script src="js/jquery-form.js"></script>
<!-- script src="script/myjs/product.js"></script-->
<script src="script/myjs/reserve.js"></script>
<script>
var pageCount = 1;
var currentPage = 0;

var search = "";
var first = 0;
var second = 0;
var size = 20;

var condition = false;
var deleteFlag = false;
/**
 * 获取产品列表
 */
function getProduct(obj){
	if(!condition && !deleteFlag && size == $("#pageSize").val() && (obj == 0 || obj == currentPage || obj > pageCount))
		return false;
	if(condition){
		search = $(".search-key").val();
		first = $(".category-first").val();
		second = $(".category-second").val();		
	}
	size = $("#pageSize").val();
	var url="/BeautyClub/product/product.do?page="+obj+"&size="+size+"&first="+first+"&second="+second+"&search="+search;	
	url=encodeURI(url);
	var tableNode = $(".product-content");	
	jQuery.post(url,{},function(data)
	{			
		var innerHtm = "";
		if(data!=null && data!="" && data.length>0)
		{				
			for(var i=1;i<data.length;i++)
			{				
				var pId = data[i].pId==null?"":data[i].pId; 
				var pName = data[i].pName==null?"":data[i].pName;
				var titlePic = data[i].titlePic==null?"":data[i].titlePic;
				var time = data[i].time==null?new Date():new Date(data[i].time);				
				var price = data[i].price==null?"未知":data[i].price;
				var currentPrice = data[i].currentPrice==null?"未知":data[i].currentPrice;
				var sales = data[i].sales==null?"无":data[i].sales;
				innerHtm += "<tr class='tbl-item'><td class='img' style='width:151px;'>";
				innerHtm += "<input type='hidden' value='"+pId+"' class='productId'/>";
				innerHtm += "<img width='120' height='80' src='upload/"+titlePic+"' alt='' title=''/></td>";
				innerHtm += "<td class='td-block'><p class='date'>"+time.toLocaleString()+"</p>";
				innerHtm += "<p class='title'>"+pName+"</p>";
				innerHtm += "<p class='desc'>现价："+currentPrice+"&nbsp;&nbsp;&nbsp;&nbsp;原价："+price+"</p>";
				innerHtm += "<p class='date'><i class='fa fa-edit edit-Product' style='cursor:pointer' onclick='editProduct(this);'>&nbsp;编辑</i>";
				innerHtm += "&nbsp;&nbsp;<i class='fa fa-trash-o delete-Product' style='cursor:pointer' onclick='deleteProduct(this);'>&nbsp;删除</i></p>";
				innerHtm += "<p class='like'>销量："+sales+"</p>";
				
				innerHtm+="</td></tr>";
			}
			var totalCount = data[0].total==null?0:data[0].total;
			$("#totalCount").text(totalCount);
			var pageNode = $('#newpage');
			var pageInner = "";
			if(totalCount == 0){
				$('.jplist-no-results').show();
				$(".dibu-r").hide();
			}else{
				var page = totalCount/parseInt(size)+(totalCount%parseInt(size)==0?0:1);				
				page = parseInt(page);				
				pageCount = page;				
				var j = 1;
				var k = page;
				if(obj > 4 && page > 7){
					pageInner += "<A ><li>...</li></A>";
					if(page - obj < 3)
						j = page-6;
					else
						j = (obj - 3) > 0?obj-3:1;
					k = (page - obj) > 3?obj+3:page;
				}
				for(var i=0;j<=k&&i<7;i++,j++){
					if(j == obj){
						pageInner += "<A ><li style='color:#fd9162'>"+j+"</li></A>";
						$("#prePage").attr("onclick","getProduct("+1+")");
						$("#postPage").attr("onclick","getProduct("+page+")");
						currentPage = obj;
					}
					else
						pageInner += "<A onclick='getProduct("+j+")'><li>"+j+"</li></A>";
				}
				if(page > 7 && page-obj > 3){
					pageInner += "<A ><li>...</li></A>";
				}
				$('.jplist-no-results').hide();
				deleteFlag = false;
				$(".dibu-r").show();
			}			
			pageNode.html(pageInner);
			tableNode.html(innerHtm);
		}else{
			$('.jplist-no-results').show();
			$("#totalCount").text(0);
			$(".dibu-r").hide();
		}
		
     },"json");	
}

/**
 * 搜索按钮点击
 */
function searchBtnClick(){
	condition = true;
	getProduct(1);
}

/**
 * 编辑产品
 */
function editProduct(obj){	
	var a = $(obj).parents("tr:first");	
	var val = a.find(".productId").val();
	$.ajax({
        url:"/BeautyClub/product/get_editinfo.do",
        type:'POST',
        dataType:'json',
        contentType:"application/json",
        data:JSON.stringify({"pId":val}),
        async:false,
        success:function(data){
        	if(data!=null && data != ""){
        		$(".edit-pId").val(data.pId);
        		$(".product-name").val(data.pName);
            	$(".old-price").val(data.price);
            	$(".current-price").val(data.currentPrice); 
            	$(".sales").val(data.sales);            	
            	if(data.category != null && data.category != "" && data.category.length > 0){            		
            		var innerHtml = "<option value='0'>--请选择--</option>";
            		for(var i = 0; i < data.category.length; i++){
            			if(data.parentId == data.category[i].cId)
            				innerHtml+="<option value='"+data.category[i].cId+"' selected>"+data.category[i].cName+"</option>";
            			else
            				innerHtml+="<option value='"+data.category[i].cId+"'>"+data.category[i].cName+"</option>";
            		}            		
            		$(".edit-first").html(innerHtml);
            		getEditSecond(data.cId);
            	}            	        	
  		  		$('#dec-uploadImg-show').attr("src","upload/"+data.images);
  		  		$('#dec-uploadImg-show').css({'width':'390px'});
  		  		$("#dec-scroll").css({'height':'400px','width':'400px'});
		  		$('#logo-uploadImg-show').attr("src","upload/"+data.titlePic);
		  		$('#logo-uploadImg-show').css({'height':'100px','width':'100px'});
		  		$('.modal-container').show();		  		
        	}else{
        		layer.msg('获取产品详细信息失败！', { icon: 5 });
        	}
        },
        error:function(result){
        	layer.msg('与服务器连接失败！', { icon: 5 });
        }
    });
	
}

/**
 * 产品编辑时获取产品二级类别
 */
function getEditSecond(obj){	
	var id=$(".edit-first").val();	
	if(id=='0'){
		$(".edit-second").html("<option value='0' selected >--请选择--</option>");
		return false;
	}	
	 var url="/BeautyClub/category/get_category.do?parent=";
	 url += id;
	 var selectNode = $(".edit-second");
	 jQuery.post(url,{},function(data)
	 {
			var innerHtm = "<option value='0'>--请选择--</option>";
			if(data!=null && data!="" && data.length>0)
			{
				for(var i=0;i<data.length;i++)
				{
					var typeId = data[i].cId==null?"":data[i].cId; 
					var typeName = data[i].cName==null?"":data[i].cName;
					if(obj == typeId)
						innerHtm+="<option value='"+typeId+"' selected>"+typeName+"</option>";
					else
						innerHtm+="<option value='"+typeId+"'>"+typeName+"</option>";
				}
			}
			selectNode.html(innerHtm);			
	 },"json");
}

/**
 * 删除产品
 */
function deleteProduct(obj){	
	var a = $(obj).parents("tr:first");	
	var val = a.find(".productId").val();	
	layer.confirm('您确定要删除吗？', {
        closeBtn: 2,
        title: '提示',
        btn: ['确定', '取消']
    }, function (index, layero){
    	$.ajax({
            url:"/BeautyClub/product/delete_product.do",
            type:'POST',
            dataType:'json',
            contentType:"application/json",
            data:JSON.stringify({"pId":val}),
            async:false,
            success:function(data){
            	if(data==true){
            		deleteFlag = true;
            		getProduct(currentPage);
            		layer.msg('删除成功！', { icon: 6 });
            	}else{
            		layer.msg('删除失败！', { icon: 5 });
            	}
            },
            error:function(result){
            	layer.msg('删除失败！', { icon: 5 });
            }
        });
    	layer.close(index);
    }, function (index) {
        //取消按钮的回调函数（默认为关闭询问框）
    });
}

//关闭弹出框
function hideModal(){
	$('.modal-container').hide();
	$(".edit-pId").val("");
	$(".product-name").val("");
	$(".old-price").val("");
	$(".current-price").val(""); 
	$(".sales").val("");
	$("#dec-uploadImg").val("");
	$('#dec-uploadImg-show').attr("src","");
	$('#dec-uploadImg-show').css({'width':'0px'});
	$("#dec-scroll").css({'height':'0px','width':'0px'});
	$('#logo-uploadImg').val("");
	$('#logo-uploadImg-show').attr("src","");
	$('#logo-uploadImg-show').css({'height':'0px','width':'0px'});
}

</script>

<script>
$(function(){
	$('#logo-uploadImg').change(function(){
    		console.log(this)
    		var error = false;
    		var name = $("#logo-uploadImg").val();
    		if(name == null || name == "")
	  			return false;
	  		var file = document.getElementById('logo-uploadImg').files[0];
	  		if (file) {
		  		var fileType = name.substring(name.lastIndexOf(".")+1).toLowerCase();		  		
		  		if(fileType != "jpg" && fileType != "jpeg" && fileType != "png"){
		  			layer.alert("图片上传格式只支持jpg/jpeg/png",{icon:0});
	  		  		error = true;
		  		}else if (file.size > 1024 * 1024 * 5){
		  			layer.alert("文件不能大于5M",{icon:0});
      		  		error = true;
      	  		}
	  		}
	  		if(error){
	  			$('#logo-uploadImg').val("");
  		  		$('#logo-uploadImg-show').attr("src","");
  		  		$('#logo-uploadImg-show').css({'height':'0px','width':'0px'});
  		  		return false;
	  		}
	  		// 上传设置
	    	var options = {
	            // 规定把请求发送到那个URL
	            url: "/BeautyClub/product/uploadPic.do?name=titlePic",
	            // 请求方式
	            type: "post",
	            // 服务器响应的数据类型
	            dataType: "json",
	            // 请求成功时执行的回调函数
	            success: function(data, status, xhr) {	                    
	                if(data.status == true){	                	
	                	var img = $('#logo-uploadImg-show');
	            		if(file){
	            			img[0].src = window.URL.createObjectURL(file);
	            			$(img[0]).css({'height':'100px','width':'100px'});
	            		}
	                }else{
	                	$('#logo-uploadImg').val("");
	                	layer.alert(data.msg,{icon:2});
            		}
	            },
	            error: function(){
	            	$('#logo-uploadImg').val("");
	            	layer.alert("上传失败！",{icon:2});
	            }
	    	};	  		
	    	$("#titlePicForm").ajaxSubmit(options);
    	});
    	
    	$('#dec-uploadImg').change(function(){
    		console.log(this)
    		error = false;
    		var name = $("#dec-uploadImg").val();
    		if(name == null || name == "")
	  			return false;
	  		var file = document.getElementById('dec-uploadImg').files[0];
	  		if (file) {
		  		var fileType = name.substring(name.lastIndexOf(".")+1).toLowerCase();		  		
		  		if(fileType != "jpg" && fileType != "jpeg" && fileType != "png"){
		  			layer.alert("图片上传格式只支持jpg/jpeg/png",{icon:0});
	  		  		error = true;
		  		}else if (file.size > 1024 * 1024 * 5){
		  			layer.alert("文件不能大于5M",{icon:0});
      		  		error = true;
      	  		}
	  		}
	  		if(error){
	  			$("#dec-uploadImg").val("");
  		  		$('#dec-uploadImg-show').attr("src","");
  		  		$('#dec-uploadImg-show').css({'width':'0px'});
  		  		$("#dec-scroll").css({'height':'0px','width':'0px'});
  		  		return false;
	  		}
	  		// 上传设置
	    	var options = {
	            // 规定把请求发送到那个URL
	            url: "/BeautyClub/product/uploadPic.do?name=decPic",
	            // 请求方式
	            type: "post",
	            // 服务器响应的数据类型
	            dataType: "json",
	            // 请求成功时执行的回调函数
	            success: function(data, status, xhr) {	                    
	                if(data.status == true){	                	
	                	var img = $('#dec-uploadImg-show');
	            		if(file){
	            			img[0].src = window.URL.createObjectURL(file);
	            			$("#dec-scroll").css({'height':'400px','width':'400px'});
	            			$(img[0]).css({'width':'390px'})
	            		}	            		
	                }else{
	                	$("#dec-uploadImg").val("");
	                	layer.alert(data.msg,{icon:2});
            		}
	            },
	            error: function(){
	            	$("#dec-uploadImg").val("");
	            	layer.alert("上传失败！",{icon:2});
	            }
	    	};
	    	$("#decPicForm").ajaxSubmit(options);    		
    	});
});

function submitProduct() {
	var pId=$(".edit-pId").val();
	if(pId==null || pId==""){		
		layer.alert("编辑失败！请刷新页面",{icon:0});
		return false;
	}
	
	var pName = $(".product-name").val();
	if(pName==null || pName==""){
		layer.alert("请输入产品名！",{icon:0});
		return false;
	}
	var parent = $(".edit-first").val();
	var cId = $(".edit-second").val();	
	if(parent==null || parent=="" || parent=="0" ||
		cId==null || cId=="" || cId=="0"){
		layer.alert("请选择类别！",{icon:0});
		return false;
	}
	var price = $(".old-price").val();
	var currentPrice = $(".current-price").val();
	if(price==null || currentPrice==null || price=="" || currentPrice==""){
		layer.alert("请填写价格！",{icon:0});
		return false;
	}
	
	$.ajax({			
		type: "POST",
		url:"/BeautyClub/product/edit.do",
		data:$('#productForm').serialize(),// 你的formid	
	    error: function(data) {	
            layer.alert("与服务器连接失败！",{icon:2});
	    },
	    success: function(data) {
	    	if(data == "true"){                	
            	$(".product-name").val("");
            	$(".old-price").val("");
            	$(".current-price").val(""); 
            	$(".sales").val("");
            	$("#dec-uploadImg").val("");
  		  		$('#dec-uploadImg-show').attr("src","");
  		  		$('#dec-uploadImg-show').css({'width':'0px'});
  		  		$("#dec-scroll").css({'height':'0px','width':'0px'});
  		  		$('#logo-uploadImg').val("");
		  		$('#logo-uploadImg-show').attr("src","");
		  		$('#logo-uploadImg-show').css({'height':'0px','width':'0px'});
		  		layer.alert("保存成功！",{icon:1});
		  		$('.modal-container').hide();
            }else{
            	layer.alert(data,{icon:2});
            }
	    }
	});		
}
</script>

</body>
</html>